/**
 * 
 */
package cz.cuni.mff.abacs.burglar.logics.planning;

import cz.cuni.mff.abacs.burglar.logics.planning.instructions.Instruction;


/**
 * Abstract base class of the handler objects.
 * 
 * @author abacs
 *
 */
public abstract class PlannerHandlerBase {
	
	/** Linux specific */
	protected static int EXIT_VALUE_SUCCESS = 0;
	
	/** '/' terminated path to the problems directory. */
	protected static final String SUBPATH_PROBLEMS = "pddl/problems/";
	/** '/' terminated path to the domains directory. */
	protected static final String SUBPATH_DOMAINS = "pddl/domains/";
	
	protected static final String STR_MOVE = "MOVE";
	protected static final String STR_ENTER_OBSERVED = "ENTER_OBSERVED";
	protected static final String STR_ENTER_UNOBSERVED = "ENTER_UNOBSERVED";
	protected static final String STR_OPEN = "OPEN";
	protected static final String STR_CLOSE = "CLOSE";
	protected static final String STR_UNLOCK = "UNLOCK";
	protected static final String STR_LOCK = "LOCK";
	protected static final String STR_PICK_UP = "PICK_UP";
	protected static final String STR_TAKE_CLOTHES = "TAKE_CLOTHES";
	protected static final String STR_USE = "USE";
	
	// -------------------------------------------------------------------------
	
	
	/**
	 * Translates the instruction code.
	 * 
	 * @param instruction string representation of the instruction name
	 * @return 
	 */
	protected static Instruction.code getInstructionCode(String instruction) {
		
		if(instruction.equals(PlannerHandlerBase.STR_MOVE))
			return Instruction.code.COMPLEX_MOVE;
		if(instruction.equals(PlannerHandlerBase.STR_OPEN))
			return Instruction.code.OPEN;
		if(instruction.equals(PlannerHandlerBase.STR_CLOSE))
			return Instruction.code.CLOSE;
		if(instruction.equals(PlannerHandlerBase.STR_UNLOCK))
			return Instruction.code.UNLOCK;
		if(instruction.equals(PlannerHandlerBase.STR_LOCK))
			return Instruction.code.LOCK;
		if(instruction.equals(PlannerHandlerBase.STR_PICK_UP))
			return Instruction.code.PICK_UP;
		if(instruction.equals(PlannerHandlerBase.STR_ENTER_OBSERVED))
			return Instruction.code.ENTER_DOOR;
		if(instruction.equals(PlannerHandlerBase.STR_ENTER_UNOBSERVED))
			return Instruction.code.ENTER_DOOR;
		if(instruction.equals(PlannerHandlerBase.STR_TAKE_CLOTHES))
			return Instruction.code.TAKE_CLOTHES;
		if(instruction.equals(PlannerHandlerBase.STR_USE))
			return Instruction.code.USE;
		
		return Instruction.code.UNDEFINED;
	}
	
	
}
